const util = require('../utils/util.js');

const url = 'https://www.agribigdata.net/CloudRanch/';
const local = 'http://192.168.43.212:8080/CloudRanch/';
const cxh = 'http://192.168.1.90:8080/CloudRanch/';

const wxRequest = (param, url) => {
  wx.request({
    url: url,
    data: param.data || {},
    header: param.header || {'content-type': 'application/x-www-form-urlencoded;charset=utf-8'},
    success(res) {param.success ? param.success(res) : console.log('请求成功！');},
    fail(res) {util.showToast('网速较慢，请稍后重试！', 'none');},
    complete(res) {if (param.complete) {param.complete(res);}}
  })
}

const addFile = (param) => {
  console.log(param.data.path);
  wx.uploadFile({
    url: url + 'uploadFile',
    filePath: param.data.filePath,
    name: 'file',
    formData: {
      account: param.data.userId,
      path: param.data.path
    },
    success(res) {
      param.success ? param.success(res) : console.log('请求成功！');
    },
    fail(res) {
      console.error(res);
      util.showToast('网速较慢，请稍后重试！', 'none');
    },
    complete(res) {
      if (param.complete) {
        param.complete(res);
      }
    }
  })
}

// 其他操作
const login = (param) => {
  wxRequest(param, url + 'Login');
}
const register = (param) => {
  wxRequest(param, url + 'register');
}
const clearRecords = (param) => {
  wxRequest(param, url + 'clearRecords');
}
const wxLogin = (param) => {
  wxRequest(param, url + 'wxLogin');
}
const createQr = (param) => {
  wxRequest(param, url + 'createQr');
}
const bindAccount = (param) => {
  wxRequest(param, url + 'wxAddAccount');
}
const createAccount = (param) => {
  wxRequest(param, url + 'wxCreateAccount');
}
const createAccountQR = (param) => {
  wxRequest(param, url + 'createAccountQR');
}
// 增
const addHistoricalSearchRecord = (param) => {
  wxRequest(param, url + 'addHistoricalSearchRecord');
}
const addCropType = (param) => {
  wxRequest(param, url + 'addCropType');
}
const addPlanting = (param) => {
  wxRequest(param, url + 'addPlanting');
}
const addFertilizer = (param) => {
  wxRequest(param, url + 'addFertilizer');
}
const addIrrigate = (param) => {
  wxRequest(param, url + 'addIrrigate');
}
const addInsectAttack = (param) => {
  wxRequest(param, url + 'addInsectAttack');
}
const addHarvest = (param) => {
  wxRequest(param, url + 'addHarvest');
}
const addCropProduce = (param) => {
  wxRequest(param, url + 'addCropProduce');
}
const addSiteImage = (param) => {
  wxRequest(param, url + 'addSiteImage');
}
const addPlaceImage = (param) => {
  wxRequest(param, url + 'addPlaceImage');
}
const addGood = (param) => {
  wxRequest(param, url + 'addGood');
}
const addPlaceInfo = (param) => {
  wxRequest(param, url + 'addPlaceInfo');
}
const addClaim = (param) => {
  wxRequest(param, url + 'changePlaceAccount');
}
const addLiveStockSpecies = (param) => {
  wxRequest(param, url + 'addLiveStockSpecies');
}
const addAddLiveStock = (param) => {
  wxRequest(param, url + 'addAddLiveStock');
}
const addFeed = (param) => {
  wxRequest(param, url + 'addFeed');
}
const addYiMiao = (param) => {
  wxRequest(param, url + 'addYiMiao');
}
const addQuarantine = (param) => {
  wxRequest(param, url + 'addQuarantine');
}
const addSlaughter = (param) => {
  wxRequest(param, url + 'addSlaughter');
}
const addCertification = (param) => {
  wxRequest(param, url + 'addCertification');
}
const addFungusType = (param) => {
  wxRequest(param, url + 'addFungusType');
}
const addPlantFungus = (param) => {
  wxRequest(param, url + 'addPlantFungus');
}
const addWarehouse = (param) => {
  wxRequest(param, url + 'addWarehouse');
}
const addStorage = (param) => {
  wxRequest(param, url + 'addStorage');
}
const addEnterprise = (param) => {
  wxRequest(param, url + 'enterprise/addEnterprise');
}
const addEnetrpriseImage = (param) => {
  wxRequest(param, url + 'enterpriseImage/addEnetrpriseImage');
}
const addManager = (param) => {
  wxRequest(param, url + 'account_site/addAccount_site');
}
//删
const delSiteImage = (param) => {
  wxRequest(param, url + 'delSiteImage');
}
const delPlaceImage = (param) => {
  wxRequest(param, url + 'delPlaceImage');
}
const delEnterpriseImage = (param) => {
  wxRequest(param, url + 'enterpriseImage/delEnterpriseImage');
}
const delCropType = (param) => {
  wxRequest(param, url + 'delCropType');
}
const delFungusType = (param) => {
  wxRequest(param, url + 'delFungusType');
}
const delPlantFungus = (param) => {
  wxRequest(param, url + 'delPlantFungus');
}
const delPlanting = (param) => {
  wxRequest(param, url + 'delPlanting');
}
const delFertilizer = (param) => {
  wxRequest(param, url + 'delFertilizer');
}
const delIrrigate = (param) => {
  wxRequest(param, url + 'delIrrigate');
}
const delInsectAttack = (param) => {
  wxRequest(param, url + 'delInsectAttack');
}
const delHarvest = (param) => {
  wxRequest(param, url + 'delHarvest');
}
const delCropProduce = (param) => {
  wxRequest(param, url + 'delCropProduce');
}
const delStorage = (param) => {
  wxRequest(param, url + 'delStorage');
}
const delLiveStockSpecies = (param) => {
  wxRequest(param, url + 'delLiveStockSpecies');
}
const delAddLiveStock = (param) => {
  wxRequest(param, url + 'delAddLiveStock');
}
const delFeed = (param) => {
  wxRequest(param, url + 'delFeed');
}
const delYiMiao = (param) => {
  wxRequest(param, url + 'delYiMiao');
}
const delQuarantine = (param) => {
  wxRequest(param, url + 'delQuarantine');
}
const delSlaughter = (param) => {
  wxRequest(param, url + 'delSlaughter');
}
const delGood = (param) => {
  wxRequest(param, url + 'delGood');
}
const delWarehouse = (param) => {
  wxRequest(param, url + 'delWarehouse');
}
const delCertification = (param) => {
  wxRequest(param, url + 'delCertification');
}
//改
const updateSite = (param) => {
  wxRequest(param, url + 'updateSite');
}
const updatePlaceInfo = (param) => {
  wxRequest(param, url + 'modifyPlaceInfo');
}
const updatePlace = (param) => {
  wxRequest(param, url + 'updatePlace');
}
const updateEnterprise = (param) => {
  wxRequest(param, url + 'enterprise/modifiyEnterprise');
}
const updatePlantation = (param) => {
  wxRequest(param, url + 'plantation/modifiyPlantation');
}
// 查
const querySitesByKeyword = (param) => {
  wxRequest(param, url + 'searchSites');
}
const queryHistoricalSearchRecord = (param) => {
  wxRequest(param, url + 'queryHistoricalSearchRecord');
}
const querySite = (param) => {
  wxRequest(param, url + 'plantation/queryPlantation');
}
const querySiteImages = (param) => {
  wxRequest(param, url + 'querySiteImages');
}
const queryPlaceImage = (param) => {
  wxRequest(param, url + 'queryPlaceImage');
}
const queryAccountData = (param) => {
  wxRequest(param, url + 'getAccountData');
}
const querySiteLocations = (param) => {
  wxRequest(param, url + 'querySiteLocations');
}
const queryPlacesBySiteId = (param) => {
  wxRequest(param, url + 'famerGetUser');
}
const queryOverallsBySiteId = (param) => {
  wxRequest(param, url + 'queryOverallsBySiteId');
}
const queryPlaces = (param) => {
  wxRequest(param, url + 'queryPlaces');
}
const queryPlaceInfo = (param) => {
  wxRequest(param, url + 'queryPlaceInfo');
}
const queryPlaceLocations = (param) => {
  wxRequest(param, url + 'queryPlaceLocations');
}
const querySitesByUserId = (param) => {
  wxRequest(param, url + 'plantation/entGetPlantation');
}
const queryCropType = (param) => {
  wxRequest(param, url + 'queryCropType');
}
const queryPlanting = (param) => {
  wxRequest(param, url + 'queryPlanting');
}
const queryPlantById = (param) => {
  wxRequest(param, url + 'queryPlantById');
}
const queryFertilizer = (param) => {
  wxRequest(param, url + 'queryFertilizer');
}
const queryIrrigate = (param) => {
  wxRequest(param, url + 'queryIrrigates');
}
const queryInsectAttack = (param) => {
  wxRequest(param, url + 'queryInsectAttack');
}
const queryHarvest = (param) => {
  wxRequest(param, url + 'queryHarvest');
}
const queryCropProduce = (param) => {
  wxRequest(param, url + 'queryCropProduce');
}
const queryGood = (param) => {
  wxRequest(param, url + 'queryGood');
}
const queryClaim = (param) => {
  wxRequest(param, url + 'queryClaim');
}
const querySensorData = (param) => {
  wxRequest(param, url + 'querySensorData');
}
const queryLiveStockSpecies = (param) => {
  wxRequest(param, url + 'queryLiveStockSpecies');
}
const queryAddLiveStock = (param) => {
  wxRequest(param, url + 'queryAddLiveStock');
}
const queryFeed = (param) => {
  wxRequest(param, url + 'queryFeed');
}
const queryYiMiao = (param) => {
  wxRequest(param, url + 'queryYiMiao');
}
const queryQuarantine = (param) => {
  wxRequest(param, url + 'queryQuarantine');
}
const querySlaughter = (param) => {
  wxRequest(param, url + 'querySlaughter');
}
const queryOriginalInfoByPlaceId = (param) => {
  wxRequest(param, url + 'queryOriginalInfoByPlaceId');
}
const queryLiveStockSuYuan = (param) => {
  wxRequest(param, url + 'queryLiveStockSuYuan');
}
const queryCertification = (param) => {
  wxRequest(param, url + 'queryCertification');
}
const querySiteVideo = (param) => {
  wxRequest(param, url + 'querySiteVideo');
}
const queryFungusType = (param) => {
  wxRequest(param, url + 'queryFungusType');
}
const queryPlantFungus = (param) => {
  wxRequest(param, url + 'queryPlantFungus');
}
const queryWarehouse = (param) => {
  wxRequest(param, url + 'queryWarehouse');
}
const queryStorage = (param) => {
  wxRequest(param, url + 'queryStorage');
}
const wxGetClaim = (param) => {
  wxRequest(param, url + 'wxGetClaim');
}
const queryEnterprise = (param) => {
  wxRequest(param, url + 'account_enterprise/queryEnterprise');
}
const queryEnterpriseInfo = (param) => {
  wxRequest(param, url + 'enterprise/getEnterprise');
}
const queryPlantation = (param) => {
  wxRequest(param, url + 'plantation/entGetPlantation');
}
const querySinglePlantation = (param) => {
  wxRequest(param, url + 'plantation/queryPlantation');
}
const queryPlantationAccount = (param) => {
  wxRequest(param, url + 'plantation/getPlantation_account');
}
const getAllEnterprise = (param) => {
  wxRequest(param, url + 'enterprise/getAllEnterprise');
}
const queryGood_entId = (param) => {
  wxRequest(param, url + 'queryGood_entId');
}
const queryCertification_entId = (param) => {
  wxRequest(param, url + 'queryCertification_entId');
}
const queryWarehouse_entId = (param) => {
  wxRequest(param, url + 'queryWarehouse_entId');
}
const getCropOriginData_admin = (param) => {
  wxRequest(param, url + 'origin_data/admin_get_planting_origin_data');
}
const getCropOriginData = (param) => {
  wxRequest(param, url + 'origin_data/plantationAdmin_get_planting_origin_data');
}
const getFungusOriginData_admin = (param) => {
  wxRequest(param, url + 'origin_data/admin_get_fungus_origin_data');
}
const getFungusOriginData = (param) => {
  wxRequest(param, url + 'origin_data/plantationAdmin_get_fungus_origin_data');
}
const getLSOriginData_admin = (param) => {
  wxRequest(param, url + 'origin_data/admin_get_liveStock_origin_data');
}
const getLSOriginData = (param) => {
  wxRequest(param, url + 'origin_data/plantationAdmin_get_liveStock_origin_data');
}
const placeIsClaim = (param) => {
  wxRequest(param, url + 'placeIsClaim');
}
const addClaimMsg = (param) => {
  wxRequest(param, url + 'claimMsg/addClaimMsg');
}
const userGetClaim = (param) => {
  wxRequest(param, url + 'userGetClaim');
}
module.exports = {
  login,
  clearRecords,
  wxLogin,
  createQr,
  bindAccount,
  createAccount,
  createAccountQR,
  addHistoricalSearchRecord,
  addCropType,
  addPlanting,
  addFile,
  addFertilizer,
  addIrrigate,
  addInsectAttack,
  addHarvest,
  addCropProduce,
  addSiteImage,
  addPlaceImage,
  addGood,
  addPlaceInfo,
  addClaim,
  addLiveStockSpecies,
  addAddLiveStock,
  addFeed,
  addYiMiao,
  addQuarantine,
  addSlaughter,
  addCertification,
  addFungusType,
  addPlantFungus,
  addWarehouse,
  addStorage,
  addEnterprise,
  addEnetrpriseImage,
  addManager,
  delSiteImage,
  delPlaceImage,
  delEnterpriseImage,
  delCropType,
  delFungusType,
  delPlantFungus,
  delPlanting,
  delFertilizer,
  delIrrigate,
  delInsectAttack,
  delHarvest,
  delCropProduce,
  delStorage,
  delLiveStockSpecies,
  delAddLiveStock,
  delFeed,
  delYiMiao,
  delQuarantine,
  delSlaughter,
  delGood,
  delWarehouse,
  delCertification,
  updateSite,
  updatePlaceInfo,
  updatePlace,
  updateEnterprise,
  updatePlantation,
  querySitesByKeyword,
  queryHistoricalSearchRecord,
  querySite,
  querySiteImages,
  queryPlaceImage,
  queryAccountData,
  querySiteLocations,
  queryPlacesBySiteId,
  queryOverallsBySiteId,
  queryPlaces,
  queryPlaceInfo,
  queryPlaceLocations,
  querySitesByUserId,
  queryPlanting,
  queryPlantById,
  queryFertilizer,
  queryIrrigate,
  queryInsectAttack,
  queryCropType,
  queryHarvest,
  queryCropProduce,
  queryGood,
  queryClaim,
  querySensorData,
  queryLiveStockSpecies,
  queryAddLiveStock,
  queryFeed,
  queryYiMiao,
  queryQuarantine,
  querySlaughter,
  queryOriginalInfoByPlaceId,
  queryLiveStockSuYuan,
  queryCertification,
  querySiteVideo,
  queryFungusType,
  queryPlantFungus,
  queryWarehouse,
  queryStorage,
  wxGetClaim,
  queryEnterprise,
  queryEnterpriseInfo,
  queryPlantation,
  querySinglePlantation,
  queryPlantationAccount,
  getAllEnterprise,
  queryGood_entId,
  queryCertification_entId,
  queryWarehouse_entId,
  getCropOriginData_admin,
  getCropOriginData,
  getFungusOriginData_admin,
  getFungusOriginData,
  getLSOriginData_admin,
  getLSOriginData,
  placeIsClaim,
  addClaimMsg,
  userGetClaim
}